﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Text;

namespace Rison.Web.ZP
{
    public partial class Test : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            LoadTable(table1, "name1", "a.新闻信息报送");
            LoadTable(table2, "name2", "b.政府信息公开");


        }

        protected void button_click(object sender, EventArgs e)
        {
            string info = HttpContext.Current.Request.Form["name1"];
            this.Label1.Text = info;

            info = HttpContext.Current.Request.Form["name2"];
            this.Label2.Text = info;
        }

        private void LoadTable(HtmlTable t,string inputname,string inputvalue)
        {           
            HtmlTableRow tr = new HtmlTableRow();
            HtmlTableCell ce = new HtmlTableCell();
            this.Page.Controls[0].FindControl("table1");


            string aa = "10,20,3,4,5,6,7,8,,,,,";
            string[] a = aa.Split(',');
            int RowCout = (a.Length - 1)/4;

            for (int i = 0; i < RowCout-1;i++)
            {
                tr = new HtmlTableRow();

                ce = new HtmlTableCell();
                if (i==0)
                    ce.InnerHtml = inputvalue;
                else
                    ce.InnerHtml = "";

                tr.Cells.Add(ce);

                ce = new HtmlTableCell();
                ce.InnerHtml = "<input type='text' name='" + inputname + "' value='" + a[i * 4].ToString() + "' />";
                tr.Cells.Add(ce);

                ce = new HtmlTableCell();
                ce.InnerHtml = "固定电话";
                tr.Cells.Add(ce);

                ce = new HtmlTableCell();
                ce.InnerHtml = "<input type='text' name='" + inputname + "' value='" + a[i * 4 + 1].ToString() + "' />";
                tr.Cells.Add(ce);

                ce = new HtmlTableCell();
                ce.InnerHtml = "手机";
                tr.Cells.Add(ce);

                ce = new HtmlTableCell();
                ce.InnerHtml = "<input type='text' name='" + inputname + "' value='" + a[i * 4 + 2].ToString() + "' />";
                tr.Cells.Add(ce);

                ce = new HtmlTableCell();
                ce.InnerHtml = "邮箱";
                tr.Cells.Add(ce);

                ce = new HtmlTableCell();
                ce.InnerHtml = "<input type='text' name='" + inputname + "' value='" + a[i * 4 + 3].ToString() + "' />";
                tr.Cells.Add(ce);

                t.Rows.Add(tr);
            } 
        }

        
    }
}
